#ifndef	_my_physical_
#define _my_physical_

#include <avr/io.h>
#include "define.h"

//define MASK
#define MASK_IO		0x07

//define for io
#define NO_INPUT    0xff
#define OUTPUT_DIR	0xff
#define INPUT_DIR	0x00
#define OUTRESERVE  4
#define OUTDIR      5
#define OUTLED      6 

#define INPUT1      0
#define INPUT2      1
#define INPUT3      2

//define for Switch
#define SW_0		5 //B
#define SW_1		6 //B	
#define	SW_2		3 //G	
#define	SW_3		4 //G

#define SW_3_ON		0x08
#define SW_2_ON		0x04
#define SW_1_ON		0x02
#define SW_0_ON		0x01

//define for motor
#define	PWM_C1		3 //E
#define	PWM_C2		4 //E
#define PWM_C3		5 //E
#define PWM_C4		4 //B
#define PWM_C5		7 //B

//declare variable
extern unsigned char outdir;

#define   GET_BUTTON_MACRO(input,button_MASK) ((input & (~button_MASK))? 0:1)
#define   GET_DC3SENSOR(input,MASK) ((input & (~MASK))? 0:1)
//declare for functions
void init_physical(unsigned char *_input1,unsigned char *_input2, unsigned char *_input3, unsigned char *_input_dipsw);

void writeIO(unsigned char ID, unsigned char val);
unsigned char readIO(unsigned char ID);

//void updateOutput(void);
void updateInput(unsigned char *_input1,unsigned char *_input2, unsigned char *_input3, unsigned char *_input_dipsw);
void updateInput1(unsigned char *_input1,unsigned char *_input2, unsigned char *_input3, unsigned char *_input_dipsw);
unsigned char read_dipsw(void);
unsigned char get_button(unsigned char _input3,unsigned char mask);
unsigned char get_sensor(unsigned char _input2,unsigned char mask1);
#endif
